import http from "@/utils/http";
import {EnumAlias} from "@/utils/common";

export function orgTree(params?: object) {
  return http({
    url: `/${EnumAlias.PROJECT}/${EnumAlias.MODULE_SYS}/org/tree`,
    method: "get",
    params
  });
}

export function orgTreeByType(params?: any) {
  return http({
    url: `/${EnumAlias.PROJECT}/${EnumAlias.MODULE_SYS}/org/tree/${params.orgType}/${params.orgId}`,
    method: "get",
    params
  });
}

export function posList(params?: object) {
  return http({
    url: `/${EnumAlias.PROJECT}/${EnumAlias.MODULE_SYS}/pos/list`,
    method: "get",
    params
  });
}

export function userPage(params?: object) {
  return http({
    url: `/${EnumAlias.PROJECT}/${EnumAlias.MODULE_SYS}/user/page`,
    method: "get",
    params
  });
}
export function userDetail(params?: object) {
  return http({
    url: `/${EnumAlias.PROJECT}/${EnumAlias.MODULE_SYS}/user/detail`,
    method: "get",
    params
  });
}

export function userDelete(data?: object) {
  return http({
    url: `/${EnumAlias.PROJECT}/${EnumAlias.MODULE_SYS}/user/delete`,
    method: "post",
    data
  });
}

export function userAdd(data?: object) {
  return http({
    url: `/${EnumAlias.PROJECT}/${EnumAlias.MODULE_SYS}/user/add`,
    method: "post",
    data
  });
}
export function userUpdate(data?: object) {
  return http({
    url: `/${EnumAlias.PROJECT}/${EnumAlias.MODULE_SYS}/user/update`,
    method: "post",
    data
  });
}
//个人中心修改个人信息
export function userEdit(data?: object) {
  return http({
    url: `/${EnumAlias.PROJECT}/${EnumAlias.MODULE_SYS}/user/changeInfo`,
    method: "post",
    data
  });
}
//个人中心修改个人头像
export function userChangeAvatar(data?: object) {
  return http({
    url: `/${EnumAlias.PROJECT}/${EnumAlias.MODULE_SYS}/user/changeAvatar`,
    method: "post",
    data
  });
}
//重置密码
export function resetPwd(data?: object) {
  return http({
    url: `/${EnumAlias.PROJECT}/${EnumAlias.MODULE_SYS}/user/resetPwd`,
    method: "post",
    data
  });
}
//获取用户对应角色
export function ownRole(params?: object) {
  return http({
    url: `/${EnumAlias.PROJECT}/${EnumAlias.MODULE_SYS}/user/ownRole`,
    method: "get",
    params
  });
}
//角色授权
export function grantRole(data?: object) {
  return http({
    url: `/${EnumAlias.PROJECT}/${EnumAlias.MODULE_SYS}/user/grantRole`,
    method: "post",
    data
  });
}
//修改密码
export function userupdatePwd(data?: object) {
  return http({
    url: `/${EnumAlias.PROJECT}/${EnumAlias.MODULE_SYS}/user/changePwd`,
    method: "post",
    data
  });
}
